﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ZK.YHP_TransManage.Com
{
    /// <summary>
    /// 磅单计算的工具类
    /// </summary>
    public class BDTools
    {
        /// <summary>
        /// 扣吨量
        /// </summary>
        /// <param name="jz"></param>
        /// <param name="tjz"></param>
        /// <returns></returns>
        public static string GetDeductionTon(string jz, string tjz)
        {
            string res = "";
            jz = string.IsNullOrWhiteSpace(jz) ? "0" : jz;
            tjz = string.IsNullOrWhiteSpace(tjz) ? "0" : tjz;
            double djz = Convert.ToDouble(jz);
            double dtjz = Convert.ToDouble(tjz);
            double ddifference = djz - dtjz;
            if (ddifference > 0)
            {
                res = ddifference.ToString("f2");
            }
            return res;
        }
        /// <summary>
        /// 扣吨金额
        /// </summary>
        /// <param name="dw"></param>
        /// <param name="price"></param>
        /// <returns></returns>
        public static string GetDeductionMoney(string dw, string price)
        {
            string res = "";
            dw = string.IsNullOrWhiteSpace(dw) ? "0" : dw;
            price = string.IsNullOrWhiteSpace(price) ? "0" : price;
            double ddw = Convert.ToDouble(dw);
            double dprice = Convert.ToDouble(price);
            if (ddw > 0)
            {
                res = (ddw * dprice).ToString("f2");
            }
            return res;
        }

        public static string GetFreight(string tjz, string yf, string dm)
        {
            string res = "";
            tjz = string.IsNullOrWhiteSpace(tjz) ? "0" : tjz;
            double dtjz = Convert.ToDouble(tjz);
            yf = string.IsNullOrWhiteSpace(yf) ? "0" : yf;
            double dyf = Convert.ToDouble(yf);
            dm = string.IsNullOrWhiteSpace(dm) ? "0" : dm;
            double ddm = Convert.ToDouble(dm);
            res = (dtjz * dyf - ddm).ToString("f2");
            return res;
        }
    }
}
